package cricket_behaviour

import (
	"longmen/server/config/global"
	"longmen/server/internal/services/nami/services/sports/cricket"
	"longmen/server/pkg/db/mysql/models/models_sports"
)

type (
	TeamApiResponse struct {
		Code  int `json:"code"`
		Query struct {
			Total int    `json:"total"`
			Type  string `json:"type"`
			ID    int    `json:"id"`
			MinID int    `json:"min_id"`
			MaxID int    `json:"max_id"`
			Limit int    `json:"limit"`
		} `json:"query"`
		Results []Team `json:"results"`
	}
	Team struct {
		ID           int    `json:"id"`             // 球队id
		NameZh       string `json:"name_zh"`        // 中文名称
		NameZht      string `json:"name_zht"`       // 粤语名称
		NameEn       string `json:"name_en"`        // 英文名称
		ShortNameZh  string `json:"short_name_zh"`  // 中文简称
		ShortNameZht string `json:"short_name_zht"` // 粤语简称
		ShortNameEn  string `json:"short_name_en"`  // 英文简称
		Abbr         string `json:"abbr"`           // 简称
		Suffix       string `json:"suffix"`         // 后缀
		Logo         string `json:"logo"`           // 球队logo
		Gender       int    `json:"gender"`         // 性别
		National     int    `json:"national"`       // 是否国家队
		UpdatedAt    int    `json:"updated_at"`     // 更新时间
	}
)

func (r TeamApiResponse) Interface() []cricket.InsertTeamInterface {
	a := make([]cricket.InsertTeamInterface, 0)
	for _, record := range r.Results {
		a = append(a, record)
	}
	return a
}

func (c Team) Get() models_sports.CricketTeam {
	global.Log.Debugf("获得板球球队最后更新时间为:%v", c.UpdatedAt)
	return models_sports.CricketTeam{
		ID:           c.ID,
		NameZh:       c.NameZh,
		NameZht:      c.NameZht,
		NameEn:       c.NameEn,
		ShortNameZh:  c.ShortNameZh,
		ShortNameZht: c.ShortNameZht,
		ShortNameEn:  c.ShortNameEn,
		Abbr:         c.Abbr,
		Suffix:       c.Suffix,
		Logo:         c.Logo,
		Gender:       c.Gender,
		National:     c.National,
		UpdatedAt:    c.UpdatedAt,
	}
}
